<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>出车条款添加</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="${basePath!}/genius/layui/css/layui.css" media="all">

	</head>
	<body>
		<div class="layui-form layuiadmin-card-header-auto">
			<div class="layui-form-item">
				<button class="layui-btn layui-btn-primary layuiadmin-btn-admin" data-type="reset"><i
						class="layui-icon layui-icon-refresh"></i>撤销</button>
				<button class="layui-btn layui-btn-warm layuiadmin-btn-admin" data-type="save" data-aaa="123"><i
						class="layui-icon layui-icon-ok"></i>保存</button>
				<button class="layui-btn layui-btn-danger layuiadmin-btn-admin" data-type="back"><i
						class="layui-icon layui-icon-return"></i>返回</button>

			</div>
			<form class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin">
				<!-- 
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px">
					<legend>基本信息</legend>
				</fieldset> -->

				<div class="layui-form-item">
					<label class="layui-form-label">业态</label>
					<div class="layui-input-block">
						<select name="format" lay-verify="required">
							<option value="0">金虎</option>
							<option value="1">今度</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">条款顺序</label>
					<div class="layui-input-block">
						<input type="number" name="clause_index" id="clause_index" lay-verify="required"
							placeholder="请输入" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">条款名称</label>
					<div class="layui-input-block">
						<input type="text" name="clause_name" id="clause_name" lay-verify="required" placeholder="请输入"
							autocomplete="on" class="layui-input">

					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">是否拍照</label>
					<div class="layui-input-block">
						<select name="takePhoto" lay-verify="required">
							<option value="0">是</option>
							<option value="1">否</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-block">
						<select name="status" lay-verify="required">
							<option value="1">启用</option>
							<option value="0">禁用</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">答案类型</label>
					<div class="layui-input-block">
						<select name="answer_type" lay-verify="required">
							<option value="1">选择</option>
							<option value="2">填空</option>
						</select>
					</div>
				</div>
				<input type="button" class="layui-btn layui-hide layui-btn-fluid" lay-submit lay-filter="add-submit"
					id="add-submit" value="确认">
			</form>
		</div>

		<script src="${basePath!}/genius/layui/layui.js"></script>
		<script>
			let parentJson = {}

			function GetQueryString(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
				var r = window.location.search.substr(1).match(reg);
				if (r != null) return unescape(r[2]);
				return null;
			}

			function setParentJson(json) {
				parentJson = json;
			}

			function backUrl() {
				var bakUrl = parentJson.bakUrl;
				window.location.href = bakUrl;
			}

			layui.config({
				base: '${basePath!}/genius/' //静态资源所在路径
				,host:'${basePath!}'//项目访问路径
			}).extend({
				setter:'config'
			}).use(['table', 'form', 'util','laydate','setter'],function() {
				var $ = layui.$,
					form = layui.form
						, setter = layui.setter;
				parentJson.bakUrl = GetQueryString("bakUrl") || 'http://www.baidu.com';
				parentJson.jsType = GetQueryString("jsType") || 'default';
				setParentJson(parentJson);

				$('.layui-btn').on('click', function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';
				});

				var active = {
					back: function() {
						backUrl();
					},
					save: function() {
						form.on('submit(add-submit)', function(data) {
							let list = []
							let d = data.field
							$.post(setter.reqBase+'/follower/insertClause', {
								//发送添加的出车条款表单数据
								type: 'back',
								clause: data.field
							}, (res) => {
								if (res.code == 0) {
									layer.msg('添加成功', {
										icon: 1
									}, function() {
										backUrl()
									});
									// form.render()
								} else {
									layer.msg(res.msg);
								}
							})
						})
						$('[lay-filter="add-submit"]').trigger('click');
					},
					reset: function() {
						$('[lay-filter="layuiadmin-form-admin"]')[0].reset();
						form.render();
					}
				}

			})
		</script>
	</body>
</html>
